package com.pingan.internal.point.shopping.controller;

import com.alibaba.fastjson.JSON;
import com.pingan.internal.point.shopping.controller.form.AddressForm;
import com.pingan.internal.point.shopping.controller.response.DataPageList;
import com.pingan.internal.point.shopping.controller.response.ResponseData;
import com.pingan.internal.point.shopping.entity.Address;
import com.pingan.internal.point.shopping.service.AddressService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@RequestMapping("address")
public class AddressController {
    private static final Logger LOGGER = LoggerFactory.getLogger(AddressController.class);

    @Resource
    private AddressService addressService;

    @PostMapping("list")
    public @ResponseBody
    ResponseData list(@RequestBody AddressForm form){
        LOGGER.info("AddressController_list_form:{}", JSON.toJSONString(form));
        DataPageList<Address> res =  addressService.list(form.getUsername());
        LOGGER.info("AddressController_list_end");
        return ResponseData.success(res);
    }

}
